package com.schoolcloud.serve.controller;

import com.schoolcloud.common.model.R;
import com.schoolcloud.serve.entity.LostFoundCategory;
import com.schoolcloud.serve.service.LostFoundCategoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/serve/lostFound/category")
public class LostFoundCategoryController {
    private final LostFoundCategoryService lostFoundCategoryService;
    @GetMapping("/list")
    public R<List<LostFoundCategory>> getLostFoundCategoryList() {
        return R.ok(lostFoundCategoryService.list());
    }
    @GetMapping("/{id}")
    public R<LostFoundCategory> getLostFoundCategoryById(@PathVariable Integer id) {
        return R.ok(lostFoundCategoryService.getById(id));
    }
    @PostMapping
    public R<LostFoundCategory> saveLostFoundCategory(@RequestBody LostFoundCategory lostFoundCategory) {
        lostFoundCategoryService.save(lostFoundCategory);
        return R.ok(lostFoundCategory);
    }
    @PutMapping
    public R<LostFoundCategory> updateLostFoundCategory(@RequestBody LostFoundCategory lostFoundCategory) {
        lostFoundCategoryService.updateById(lostFoundCategory);
        return R.ok(lostFoundCategory);
    }
    @DeleteMapping("/{id}")
    public R deleteLostFoundCategory(@PathVariable Integer id) {
        lostFoundCategoryService.removeById(id);
        return R.ok();
    }
}
